const app = getApp(); //引入自定义头部导航

var util = require('../../utils/common.js'); //引入公共JS


import { MySearchjq } from 'mySearchjq.model.js';
var search = new MySearchjq();
var yzm = '';
var tel = '';
var unm = '';
var unm1;
Page({
  data: {
    showIcon: true,
    //显示返回键以及首页
    searchBox: true,
    //验证后显示的
    noSearch: false,
    //没有验证时显示的
    showMessage: false,
    yzFlag: true,
    searchResult: "请输入查询验证码或联系客服人员查询！",
    yzresult: ''
  },
  onLoad: function () {},
  getScancode: function () {
    var _this = this; // 允许从相机和相册扫码


    tt.scanCode({
      success: res => {
        console.log("666");
        var result = res.result;
        this.setData({
          value: result
        });
      }
    });
  },
  //点击
  formsubmin1: function (e) {
    yzm = e.detail.value; // 获取验证码

    yzm = yzm.yzm;

    if (yzm.length != 6 && yzm.length != 36 && yzm.length != 8) {
      // if (yzm.length != 6 && yzm.length != 68 && yzm.length != 8) {
      console.log("1");
      this.setData({
        searchResult: '请输入正确的验证码!'
      });
    } else {
      // 获取票据信息
      search.getPiaoJujq(yzm, res => {
        unm1 = res;
        this.setData({
          tel: unm1[0],
          noSearch: true,
          searchBox: false
        });
      });
    }
  },
  formsubmin2: function (oid_iput) {
    oid_iput = oid_iput['detail']['value']['oid_iput'];
    var uname = unm['uname'];

    if (oid_iput == '') {
      this.setData({
        yzFlag: false,
        yzresult: '数据错误，请联系客服!'
      });
    } else {
      if (tel['verification'] == 2) {
        this.setData({
          yzFlag: false,
          yzresult: '该验证码已经经过验证，无需重复验证!'
        });
      } else {
        if (oid_iput != '') {
          console.log(oid_iput);
          search.getyzjq(oid_iput, res => {
            console.log(res);
          });
          this.setData({
            yzFlag: false,
            yzresult: '验证成功,可以进场,如有疑问请联系客服!'
          });
        }
      }
    }
  },
  showMessage: function (text) {
    var that = this;
    that.setData({
      showMessage: true,
      messageContent: text
    });
    setTimeout(function () {
      that.setData({
        showMessage: false,
        messageContent: ''
      });
    }, 3000);
  },
  //分享
  onShareAppMessage: function () {
    util.sharePage();
  }
});